package sample.one;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import sample.one.model.Foo;
import sample.one.model.Shop;
import sample.one.service.FooService;
import sample.one.service.ShopService;

public class TestMain {
	public static void main(String[] args){
		ApplicationContext ctx = new ClassPathXmlApplicationContext("syt_config_sample.xml");
		
		ShopService shopService = (ShopService)ctx.getBean("shopService");
		FooService fooService = (FooService)ctx.getBean("fooService");
		//TestMain.clear(shopService, fooService);
		
		//TestMain.testA(shopService, fooService);
		TestMain.testB(shopService, fooService);
		//TestMain.testC(shopService, fooService);
		
	}
	
	
	public static void testA(ShopService shopService, FooService fooService){
		Shop shop = new Shop();
		shop.setName("shop");
		shopService.insertShop(shop);
		
		Foo foo = new Foo();
		foo.setId(1);
		foo.setName("name");
		fooService.insertFoo(foo);
		fooService.insertFoo(foo);
	}
	
	public static void testB(ShopService shopService, FooService fooService){
		
		Foo foo = new Foo();
		foo.setId(1);
		foo.setName("name");
		fooService.insertFoo(foo);
	}
	
	public static void testC(ShopService shopService, FooService fooService){
		Shop shop = new Shop();
		shop.setName("shop");
		shopService.insertShop(shop);
	}
	
	public static void clear(ShopService shopService, FooService fooService){
		shopService.clear();
		fooService.clear();
	}
}
